package com.example.wangning.mycarofcountry.db;

import com.example.mycarofcountry.entity.dao.DaoMaster;
import com.example.mycarofcountry.entity.dao.DaoSession;
import com.example.mycarofcountry.entity.dao.Recommend_Focusing;
import com.example.mycarofcountry.entity.dao.Recommend_Newslist;
import com.example.wangning.mycarofcountry.base.BaseApplication;

import java.util.List;

/**
 * Created by dllo on 16/1/18.
 */
public class BackDao {
    private static DaoMaster daoMaster;
    private static DaoSession daoSession;

    public static DaoMaster getDaoMaster() {
        if (daoMaster == null) {//静态方法只能访问静态变量(context)
            DaoMaster.DevOpenHelper helper = new DaoMaster.DevOpenHelper(BaseApplication.getContext(), "iknowyou.db", null);
            daoMaster = new DaoMaster(helper.getWritableDatabase());
        }
        return daoMaster;
    }

    public static DaoSession getDaoSession() {
        if (daoSession == null) {
            if (daoMaster == null)
                getDaoMaster();
            daoSession = daoMaster.newSession();
        }
        return daoSession;
    }



}
